package net.wanho.controller;

import lombok.SneakyThrows;
import net.wanho.service.FileService;
import net.wanho.vo.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Author：汤小洋
 * Date：2024-12-13 15:56
 * Description：<描述>
 */
@RestController
public class FileController {

    @Autowired
    private FileService fileService;

    @SneakyThrows
    @PostMapping("/upload")
    public AjaxResult upload(MultipartFile file){
        // System.out.println(file.getOriginalFilename()); // 文件名
        // System.out.println(file.getSize()); // 文件大小
        // System.out.println(file.getContentType()); // 文件类型
        // System.out.println(file.getInputStream()); // 文件流

        String url = fileService.uploadFile(file);
        return AjaxResult.success("上传成功", url);
    }

}
